using System;
using System.Data;

namespace Data.Model
{
    public class fee
    {
        public Int32 id{get;set;}
        public Int32 mintime{get;set;}
        public Int32 maxtime{get;set;}
        public Int32 basetime{get;set;}
        public Decimal basemoney{get;set;}
        public Int32 intervaltime{get;set;}
        public Decimal intervalmoney{get;set;}
        public Decimal maxintervalmoney{get;set;}
        public string cpucardtype{get;set;}
        public string biketype{get;set;}

        private string InsertSql = "insert into fee([id],[mintime],[maxtime],[basetime],[basemoney],[intervaltime],[intervalmoney],[maxintervalmoney],[cpucardtype],[biketype]) values(@id,@mintime,@maxtime,@basetime,@basemoney,@intervaltime,@intervalmoney,@maxintervalmoney,@cpucardtype,@biketype)";
        private string UpdateSql = "UPDATE fee SET [id]=@id,[mintime]=@mintime,[maxtime]=@maxtime,[basetime]=@basetime,[basemoney]=@basemoney,[intervaltime]=@intervaltime,[intervalmoney]=@intervalmoney,[maxintervalmoney]=@maxintervalmoney,[cpucardtype]=@cpucardtype,[biketype]=@biketype";

        private bool _tranByConstructFlag = false;
        public bool TranByConstructFlag{get{ return _tranByConstructFlag; } set{ _tranByConstructFlag = value; }}
        public fee(DataRow dataRow){
            if(dataRow != null){
                try{
                    this.id = dataRow["id"] is DBNull ? 0 : Convert.ToInt32(dataRow["id"]);
                    this.mintime = dataRow["mintime"] is DBNull ? 0 : Convert.ToInt32(dataRow["mintime"]);
                    this.maxtime = dataRow["maxtime"] is DBNull ? 0 : Convert.ToInt32(dataRow["maxtime"]);
                    this.basetime = dataRow["basetime"] is DBNull ? 0 : Convert.ToInt32(dataRow["basetime"]);
                    this.basemoney = dataRow["basemoney"] is DBNull ? 0 : Convert.ToDecimal(dataRow["basemoney"]);
                    this.intervaltime = dataRow["intervaltime"] is DBNull ? 0 : Convert.ToInt32(dataRow["intervaltime"]);
                    this.intervalmoney = dataRow["intervalmoney"] is DBNull ? 0 : Convert.ToDecimal(dataRow["intervalmoney"]);
                    this.maxintervalmoney = dataRow["maxintervalmoney"] is DBNull ? 0 : Convert.ToDecimal(dataRow["maxintervalmoney"]);
                    this.cpucardtype = dataRow["cpucardtype"] is DBNull ? string.Empty : Convert.ToString(dataRow["cpucardtype"]);
                    this.biketype = dataRow["biketype"] is DBNull ? string.Empty : Convert.ToString(dataRow["biketype"]);
                    this.TranByConstructFlag = true;
                }catch(Exception){ this.TranByConstructFlag = false; }
            }
        }
        public fee(){}
    }
}
